<%--
  - Author		:	Jaewon Choi
  - Date			:
  - Description	:	
  --%>
<%@ page language="java" %>
<%@ page contentType="text/html; charset=utf-8" %>
<%@ page pageEncoding="utf-8"%>
<%@ include file="/WEB-INF/pages/includes/taglibs.jspf" %>
<%@ include file="/WEB-INF/pages/includes/variables.jspf" %>
<%@ include file="/WEB-INF/pages/includes/doctype.jspf" %>
<html>
	<head>
<%@ include file="/WEB-INF/pages/includes/metatags.jspf" %>
		<title><fmt:message key="pages.title" /></title>
		<link rel="stylesheet" type="text/css" href="<c:url value="${dirStyles}/common.css" />" />
		<link rel="stylesheet" type="text/css" href="<c:url value="${dirScripts}/jqueryUi/css/ui-lightness/jquery-ui-1.8.21.custom.css" />" />

		<script type="text/javascript" src="<c:url value="${dirScripts}/jquery-1.7.2.min.js" />"></script>
		<script type="text/javascript" src="<c:url value="${dirScripts}/jquery-ui-1.8.21.custom.min.js" />"></script>
		<script type="text/javascript" src="<c:url value="${dirScripts}/common.js" />"></script>
		<script type="text/javascript">
			$(function() {
				$( ".date" ).datepicker({
					showOn: "both",
					buttonImage: "<c:url value="${dirImages}/calendar.png" />",
					buttonImageOnly: true,
					dateFormat: "yy-mm-dd",
					changeMonth: true,
					changeYear: true
				});
			});
		</script>
	</head>
	<body>
		<div class="bodyWrap">
<%@ include file="/WEB-INF/pages/includes/header.jsp" %>
<%@ include file="/WEB-INF/pages/includes/left.jsp" %>
			<div class="contWrap">
				<div class="menuTitle">통계</div>
				<div class="searchWrap">
					<form id="searchFrm" name="searchFrm" method="post">
						<ul  class="lineBlock">
							<li>
								<font>통계 종류</font>
								<select name="logType" onchange="javascript:$('.grp').attr('disabled', 'disabled').hide();$('.'+this.value).removeAttr('disabled').show();">
									<option value="appLifeCycle" <c:if test="${param.logType eq 'appLifeCycle'}"> selected="selected" </c:if>>앱 시작 횟수</option>
									<option value="downCont" <c:if test="${param.logType eq 'downCont'}"> selected="selected" </c:if>>콘텐츠 다운로드</option>
									<option value="confirmPush" <c:if test="${param.logType eq 'confirmPush'}"> selected="selected" </c:if>>푸시메시지 확인</option>
									<option value="confirmNotice" <c:if test="${param.logType eq 'confirmNotice'}"> selected="selected" </c:if>>긴급 공지 확인</option>
									<option value="appUpdate" <c:if test="${param.logType eq 'appUpdate'}"> selected="selected" </c:if>>앱 업데이트 시도</option>
									<option value="setupPush" <c:if test="${param.logType eq 'setupPush'}"> selected="selected" </c:if>>알림설정</option>
									<option value="detailedEvent" <c:if test="${param.logType eq 'detailedEvent'}"> selected="selected" </c:if>>이벤트 상세보기 조회</option>
									<option value="adClick" <c:if test="${param.logType eq 'adClick'}"> selected="selected" </c:if>>광고 클릭</option>
									<option value="adRolling" <c:if test="${param.logType eq 'adRolling'}"> selected="selected" </c:if>>광고 롤링</option>
									<option value="detailedCont" <c:if test="${param.logType eq 'detailedCont'}"> selected="selected" </c:if>>콘텐츠 조회</option>
									<option value="view" <c:if test="${param.logType eq 'view'}"> selected="selected" </c:if>>메인 화면 조회</option>
								</select>
							</li>
							<li>
								<font>검색조건</font>
								<select class="grp appLifeCycle" name="grp" <c:if test="${not empty param.logType and param.logType ne 'appLifeCycle'}"> disabled="disabled" style="display:none;" </c:if>>
									<option value="device" <c:if test="${param.grp eq 'device'}"> selected="selected" </c:if>>기기별</option>
									<option value="model" <c:if test="${param.grp eq 'model'}"> selected="selected" </c:if>>모델별</option>
									<option value="date" <c:if test="${param.grp eq 'date'}"> selected="selected" </c:if>>날짜별</option>
								</select>
								<select class="grp appLifeCycle" name="type" <c:if test="${not empty param.logType and param.logType ne 'appLifeCycle'}"> disabled="disabled" style="display:none;" </c:if>>
									<option value="uv" <c:if test="${param.type eq 'uv'}"> selected="selected" </c:if>>UV</option>
									<option value="pv" <c:if test="${param.type eq 'pv'}"> selected="selected" </c:if>>PV</option>
									<%--
									<option value="start" <c:if test="${param.type eq 'start'}"> selected="selected" </c:if>>시작</option>
									<option value="resume" <c:if test="${param.type eq 'resume'}"> selected="selected" </c:if>>Resume</option>
									<option value="quit" <c:if test="${param.type eq 'quit'}"> selected="selected" </c:if>>종료</option>
									<option value="forceQuit" <c:if test="${param.type eq 'forceQuit'}"> selected="selected" </c:if>>강제종료</option>
									<option value="sleep" <c:if test="${param.type eq 'sleep'}"> selected="selected" </c:if>>Sleep</option>
									--%>
								</select>
								<select class="grp downCont" name="grp" <c:if test="${param.logType ne 'downCont'}"> disabled="disabled" style="display:none;" </c:if>>
									<option value="content" <c:if test="${param.grp eq 'content'}"> selected="selected" </c:if>>콘텐츠</option>
									<option value="network" <c:if test="${param.grp eq 'network'}"> selected="selected" </c:if>>네트워크</option>
									<option value="device" <c:if test="${param.grp eq 'device'}"> selected="selected" </c:if>>기기별</option>
									<option value="model" <c:if test="${param.grp eq 'model'}"> selected="selected" </c:if>>모델별</option>
									<option value="date" <c:if test="${param.grp eq 'date'}"> selected="selected" </c:if>>날짜별</option>
								</select>
								<select class="grp downCont" name="type" <c:if test="${param.logType ne 'downCont'}"> disabled="disabled" style="display:none;" </c:if>>
									<option value="" <c:if test="${param.type eq ''}"> selected="selected" </c:if>>전체</option>
									<option value="start" <c:if test="${param.type eq 'start'}"> selected="selected" </c:if>>시작</option>
									<option value="restart" <c:if test="${param.type eq 'restart'}"> selected="selected" </c:if>>재시작</option>
									<option value="stop" <c:if test="${param.type eq 'stop'}"> selected="selected" </c:if>>중지</option>
									<option value="complete" <c:if test="${param.type eq 'complete'}"> selected="selected" </c:if>>완료</option>
									<option value="delete" <c:if test="${param.type eq 'delete'}"> selected="selected" </c:if>>삭제</option>
								</select>
								<select class="grp confirmPush confirmNotice appUpdate setupPush detailedEvent detailedCont" name="grp" <c:if test="${param.logType ne 'confirmPush' and param.logType ne 'confirmNotice' and param.logType ne 'appUpdate' and param.logType ne 'setupPush' and param.logType ne 'detailedEvent' and param.logType ne 'detailedCont'}"> disabled="disabled" style="display:none;" </c:if>>
									<option value="device" <c:if test="${param.grp eq 'device'}"> selected="selected" </c:if>>기기별</option>
									<option value="model" <c:if test="${param.grp eq 'model'}"> selected="selected" </c:if>>모델별</option>
									<option value="date" <c:if test="${param.grp eq 'date'}"> selected="selected" </c:if>>날짜별</option>
								</select>
								<select class="grp adClick adRolling" name="grp" <c:if test="${param.logType ne 'adClick' and param.logType ne 'adRolling'}"> disabled="disabled" style="display:none;" </c:if>>
									<option value="ad" <c:if test="${param.grp eq 'ad'}"> selected="selected" </c:if>>광고별</option>
									<option value="type" <c:if test="${param.grp eq 'type'}"> selected="selected" </c:if>>타입별</option>
									<option value="device" <c:if test="${param.grp eq 'device'}"> selected="selected" </c:if>>기기별</option>
									<option value="model" <c:if test="${param.grp eq 'model'}"> selected="selected" </c:if>>모델별</option>
									<option value="date" <c:if test="${param.grp eq 'date'}"> selected="selected" </c:if>>날짜별</option>
								</select>
								<select class="grp view" name="grp" <c:if test="${param.logType ne 'view'}"> disabled="disabled" style="display:none;" </c:if>>
									<option value="viewId" <c:if test="${param.grp eq 'viewId'}"> selected="selected" </c:if>>화면별</option>
									<option value="device" <c:if test="${param.grp eq 'device'}"> selected="selected" </c:if>>기기별</option>
									<option value="model" <c:if test="${param.grp eq 'model'}"> selected="selected" </c:if>>모델별</option>
									<option value="date" <c:if test="${param.grp eq 'date'}"> selected="selected" </c:if>>날짜별</option>
								</select>
								<select class="grp view" name="type" <c:if test="${param.logType ne 'view'}"> disabled="disabled" style="display:none;" </c:if>>
									<option value="start" <c:if test="${param.type eq 'start'}"> selected="selected" </c:if>>시작</option>
									<option value="resume" <c:if test="${param.type eq 'resume'}"> selected="selected" </c:if>>Resume</option>
									<option value="quit" <c:if test="${param.type eq 'quit'}"> selected="selected" </c:if>>종료</option>
									<option value="forceQuit" <c:if test="${param.type eq 'forceQuit'}"> selected="selected" </c:if>>강제종료</option>
									<option value="sleep" <c:if test="${param.type eq 'sleep'}"> selected="selected" </c:if>>Sleep</option>
								</select>
							</li>
							<li>
								<font>조회기간</font>
								<label>
									<input type="radio" name="dateType" class="dateType" value="0" onclick="javascript:$('.date').attr('disabled', 'true');" <c:if test="${param.dateType eq 0 || empty param.dateType}"> checked="checked" </c:if>>전체
								</label>
								<label>
									<input type="radio" name="dateType" class="dateType" value="1" onclick="javascript:$('.date').removeAttr('disabled');" <c:if test="${param.dateType eq 1}"> checked="checked" </c:if>>
									<input type="text" class="date" name="startDate" readonly="readonly" value="${param.startDate}" /> ~ <input type="text" class="date" name="endDate" readonly="readonly" value="${param.endDate}" />
								</label>
							</li>
						</ul>
						<input type="submit" class="btn" value="조회" />
					</form>
				</div>
				<table class="listTbl tbl">
					<colgroup>
						<col width="70px;" />
						<col width="*" />
						<col width="*" />
					</colgroup>
					<thead>
						<tr>
							<th>No.</th>
							<th>그룹</th>
							<th>횟수</th>
						</tr>
					</thead>
					<tbody id="loggingData">
						<c:forEach items="${logData}" var="log" varStatus="logStat">
							<tr>
								<td style="text-align: center;">${fn:length(logData)-logStat.index}</td>
								<td style="text-align: center;">
									<c:choose>
										<c:when test="${(param.logType eq 'downCont' and param.grp eq 'content') or (param.logType eq 'detailedCont' and param.grp eq 'content') }">
											<c:forEach items="${contentList}" var="content">
												<c:if test="${log.grp eq content.idx}">
													${content.name}
												</c:if>
											</c:forEach>
										</c:when>
										<c:when test="${param.logType eq 'confirmPush' and param.grp eq 'push'}">
											<c:forEach items="${gcmList}" var="gcm">
												<c:if test="${log.grp eq gcm.idx}">
													${gcm.name}
												</c:if>
											</c:forEach>
										</c:when>
										<c:when test="${param.logType eq 'confirmNotice' and param.grp eq 'notice'}">
											<c:forEach items="${noticeList}" var="notice">
												<c:if test="${log.grp eq notice.idx}">
													${notice.name}
												</c:if>
											</c:forEach>
										</c:when>
										<c:when test="${param.logType eq 'detailedEvent' and param.grp eq 'event'}">
											<c:forEach items="${eventList}" var="event">
												<c:if test="${log.grp eq event.idx}">
													${event.name}
												</c:if>
											</c:forEach>
										</c:when>
										<c:when test="${(param.logType eq 'adClick' or param.logType eq 'adRolling') and param.grp eq 'ad'}">
											<c:forEach items="${advertisingList}" var="ad">
												<c:if test="${log.grp eq ad.idx}">
													${ad.name}
												</c:if>
											</c:forEach>
										</c:when>
										<c:otherwise>
											${log.grp}
										</c:otherwise>
									</c:choose>
								</td>
								<td style="text-align: center;">${log.cnt}</td>
							</tr>
						</c:forEach>
						<c:if test="${empty logData}">
							<tr><td colspan="3" style="text-align: center;">데이터가 없습니다.</td></tr>
						</c:if>
					</tbody>
				</table>
			</div>
<%@ include file="/WEB-INF/pages/includes/footer.jsp" %>
		</div>
	</body>
</html> 